package Adapter;
import ViewHoder.MainHoder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MainAdapter extends ArrayAdapter<String>{

	Context context;
	int layout;
	String[]objectsStrings;
	MainHoder hoder;
	public MainAdapter(Context context, int resource, String[] objects) {
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.layout=resource;
		this.objectsStrings=objects;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView==null) {
			
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(layout, parent, false);
			hoder=new MainHoder();
			hoder.txtName=(TextView) convertView.findViewById(com.example.quanlithuchi.R.id.txtMainName);
			convertView.setTag(hoder);
		}
		else {
			hoder=(MainHoder) convertView.getTag();
		}
		hoder.txtName.setText(objectsStrings[position]);
		convertView.setPadding(10, 10, 10, 10);
		return convertView;
	}
	
	

}
